import { currentUserID } from "@/utils/common.js";
import { utils } from 'hi-ui';
export default {
    id: "DrugEntity",
    returnTotal: true,
    modelFile: "database/drug/dataset/DrugEntity.xml",
    sortFields: [
        "FID",
        "FNUMBER",
        "FCLASS",
        "FBARCODE",
        "FDESC",
        "FPINYIN",
        "FJIANPIN",
        "FPINYIN",
        "FENTERPRISEDESC",
        "FENTERPRISEID",
        "FUNIT",
        "FSPEC",
        "FPROADDRESS",
        "FPRICE",
        "FPURCHASINGPRICE",
        "FCOSTPRICE",
        "FBRAND",
        "FDOSAGEFORM",
        "FSTOREUPPER",
        "FSTORELOWER",
        "FPROCOMPANY",
        "FAPPROVALNUMBER",
        "FAPPROVALDATE",
        "FBUSINESSSCOPE",
        "FPRESCRICLASS",
        "FMEDICARETYPE",
        "FDRUGCLASS",
        "FSTORECOND",
        "FABC",
        "FISIMPORT",
        "FNOTE",
        "FUSERID",
        "FCREATEDATE",
        "FCOMPANY",
        "FVIPPRICE",
        "FENTERRATE",
        "FCANCELRATE",
        "FREBATE",
        "FIMG",
        "FDETAIL",
        "FISRETAIL",
        "PRODUCTIONDATE",
        "EXPIRATIONDATE"

    ],
    fields: {
        FID: {
            name: "FID", //字段ID
            label: "ID", //字段描述
            dbtype: "dbString", //数据类型
            default: {
                //默认值
                //rule: 'first', //prior   填充规则
                exps: (data) => {
                    //填充表达式
                    return utils.string.guid();
                },
            },
        },

        FNUMBER: {
            name: "FNUMBER", //字段ID
            label: "店内编码", //字段描述
            dbtype: "dbString", //数据类型
            required: true,
            length: 25,

        },

        FREBATE: {
            name: "FREBATE", //字段ID
            label: "返点", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,

        },
        FIMG: {
            name: "FIMG", //字段ID
            label: "图片", //字段描述
            dbtype: "dbString", //数据类型
            length: 250,

        },
        FDETAIL: {
            name: "FDETAIL", //字段ID
            label: "详情", //字段描述
            dbtype: "dbString", //数据类型
            length: 250,

        },

        FCLASS: {
            name: "FCLASS", //字段ID
            label: "类别", //字段描述
            dbtype: "dbString", //数据类型
            required: true,
            length: 25,

        },
        FBARCODE: {
            name: "FBARCODE", //字段ID
            label: "条形码", //字段描述
            dbtype: "dbString", //数据类型
            required: true,
            length: 25,


        },

        FDESC: {
            name: "FDESC", //字段ID
            label: "通用名称", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
            required: true,
            fireTarget: ["FPINYIN", "FJIANPIN"]
        },



        FPINYIN: {
            name: "FPINYIN", //字段ID
            label: "拼音", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
            default: {
                //默认值
                //rule: 'first', //prior   填充规则
                exps: (data) => {
                    //填充表达式
                    return utils.string.getPinyin(data.FDESC || "");
                },
            },

        },
        FJIANPIN: {
            name: "FJIANPIN", //字段ID
            label: "简拼", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
            default: {
                //默认值
                //rule: 'first', //prior   填充规则
                exps: (data) => {
                    //填充表达式
                    return utils.string.getFirstPY(data.FDESC || "");

                },
            },
        },


        FUNIT: {
            name: "FUNIT", //字段ID
            label: "单位", //字段描述
            dbtype: "dbString", //数据类型
            required: true,
            length: 5,
        },

        FSPEC: {
            name: "FSPEC", //字段ID
            label: "规格", //字段描述
            dbtype: "dbString", //数据类型
            required: true,
            length: 100,
        },

        FPROCOMPANY: {
            name: "FPROCOMPANY", //字段ID
            label: "生产厂家", //字段描述
            dbtype: "dbString", //数据类型
            length: 200,
        },
        FPROADDRESS: {
            name: "FPROADDRESS", //字段ID
            label: "生产地址", //字段描述
            dbtype: "dbString", //数据类型  
            length: 200,
        },


        FPRICE: {
            name: "FPRICE", //字段ID
            label: "零售价", //字段描述
            dbtype: "dbFloat", //数据类型

        },

        FVIPPRICE: {
            name: "FVIPPRICE", //字段ID
            label: "会员价", //字段描述
            dbtype: "dbFloat", //数据类型

        },

        FENTERRATE: {
            name: "FENTERRATE", //字段ID
            label: "进项税率", //字段描述
            dbtype: "dbFloat", //数据类型

        },

        FCANCELRATE: {
            name: "FCANCELRATE", //字段ID
            label: "销项税率", //字段描述
            dbtype: "dbFloat", //数据类型

        },

        FPURCHASINGPRICE: {
            name: "FPURCHASINGPRICE", //字段ID
            label: "进价", //字段描述
            dbtype: "dbFloat", //数据类型

        },
        FCOSTPRICE: {
            name: "FCOSTPRICE", //字段ID
            label: "成本价", //字段描述
            dbtype: "dbFloat", //数据类型

        },

        FBRAND: {
            name: "FBRAND", //字段ID
            label: "品牌", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
        },

        FDOSAGEFORM: {
            name: "FDOSAGEFORM", //字段ID
            label: "剂型", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
        },

        FSTOREUPPER: {
            name: "FSTOREUPPER", //字段ID
            label: "库存上限", //字段描述
            dbtype: "dbInt", //数据类型
            default: {
                //默认值
                //rule: 'first', //prior   填充规则
                exps: (data) => {
                    //填充表达式
                    return 200;

                },
            },
        },

        FSTORELOWER: {
            name: "FSTORELOWER", //字段ID
            label: "库存下限", //字段描述
            dbtype: "dbInt", //数据类型
            default: {
                //默认值
                //rule: 'first', //prior   填充规则
                exps: (data) => {
                    //填充表达式
                    return 10;

                },
            },
        },



        FAPPROVALNUMBER: {
            name: "FAPPROVALNUMBER", //字段ID
            label: "批准文号", //字段描述
            dbtype: "dbString", //数据类型
            required: true,
            length: 25,
        },

        FAPPROVALDATE: {
            name: "FAPPROVALDATE", //字段ID
            label: "批准日期", //字段描述
            dbtype: "dbDate", //数据类型
            length: 25,
        },

        FBUSINESSSCOPE: {
            name: "FBUSINESSSCOPE", //字段ID
            label: "经营范围分类", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
        },


        FPRESCRICLASS: {
            name: "FPRESCRICLASS", //字段ID
            label: "处方分类", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
        },

        FDRUGCLASS: {
            name: "FDRUGCLASS", //字段ID
            label: "药品分类(按功能)", //字段描述
            dbtype: "dbString", //数据类型
            // required: true,
            length: 25,
        },

        FMEDICARETYPE: {
            name: "FMEDICARETYPE", //字段ID
            label: "医保类别", //字段描述
            dbtype: "dbString", //数据类型
            required: true,
            length: 25,
        },

        FSTORECOND: {
            name: "FSTORECOND", //字段ID
            label: "储存条件", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
        },


        FABC: {
            name: "FABC", //字段ID
            label: "ABC级", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
        },

        FISIMPORT: {
            name: "FISIMPORT", //字段ID
            label: "是否进口", //字段描述
            dbtype: "dbBoolean", //数据类型
        },
        FISRETAIL: {
            name: "FISRETAIL", //字段ID
            label: "是否拆零", //字段描述
            dbtype: "dbBoolean", //数据类型
        },
        FENTERPRISEDESC: {
            name: "FENTERPRISEDESC", //字段ID
            label: "企业名称", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
        },
        FENTERPRISEID: {
            name: "FENTERPRISEID", //字段ID
            label: "企业ID", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
        },
        FNOTE: {
            name: "FNOTE", //字段ID
            label: "备注", //字段描述
            dbtype: "dbString", //数据类型
            length: 250,
        },

        FUSERID: {
            name: "FUSERID", //字段ID
            label: "创建人", //字段描述
            dbtype: "dbString", //数据类型
            readonly: true,
            default: {
                //默认值
                exps: (data) => {
                    //填充表达式
                    return currentUserID();
                },
            },
        },


        FCREATEDATE: {
            name: "FCREATEDATE", //字段ID
            label: "创建时间", //字段描述
            dbtype: "dbDate", //数据类型
            readonly: true,
            length: 25,
            default: {
                //默认值
                exps: (data) => {
                    //填充表达式
                    return utils.date.format(new Date(), "yyyy-MM-dd HH:mm:ss");
                },
            },
        },
        PRODUCTIONDATE: {
            name: "PRODUCTIONDATE", //字段ID
            label: "生产日期", //字段描述
            dbtype: "dbDate", //数据类型
            required: true,
        },

        EXPIRATIONDATE: {
            name: "EXPIRATIONDATE", //字段ID
            label: "有效期至", //字段描述
            dbtype: "dbDate", //数据类型
            required: true,
        },
        FAMOUNT: {
            name: "FAMOUNT", //字段ID
            label: "数量", //字段描述
            dbtype: "dbFloat", //数据类型
            required: true,
        },
        FSHOPDESC: {
            name: "FSHOPDESC", //字段ID
            label: "店铺", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
            required: true,
        },
        FSHOPDESCID: {
            name: "FSHOPDESCID", //字段ID
            label: "店铺编号", //字段描述
            dbtype: "dbString", //数据类型
            length: 25,
            required: true,
        },
    },
    /*  validateList: [{
         "expr": function (store) {
             var data = store.data;
             for (var i = 0; i < data.length; i++) {
                 var item = data[i];
                 if (item.FPRICE * 1 <= 0)
                     return new Error('零售价不能为零');
                 if (item.FVIPPRICE * 1 <= 0)
                     return new Error('会员价不能为零');
             }
 
         }
     }] */
}
